<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<input value="2017-12-22" id="d1" />
		<script>
			var s = d1.value;
			var firstindex = s.indexOf("-");
			var secondindex = s.indexOf("-", firstindex + 1);

			var y = s.substring(0, firstindex);

			var m = s.substring(firstindex + 1, secondindex);
			var d = s.substring(secondindex + 1);
			alert(y);
			alert(m);
			alert(d);
		</script>
	</body>

</html>